import pytest
from selenium import webdriver
from zyuekao.Page import Page
from time import sleep
from zyuekao.Page1 import Page1
from zyuekao.Page2 import Page2
@pytest.fixture()
def driver():
    driver=webdriver.Chrome()
    driver.maximize_window()
    #设置隐式等待10秒(全局生效)
    driver.implicitly_wait(10)
    yield driver
    driver.quit()

def test_163_login(driver):
    po1=Page(driver)
    po1.open_url('https://mail.163.com/')
    sleep(3)
    po1.login_kuangjia()
    sleep(2)
    po1.send_yxiang()
    sleep(2)
    po1.send_password()
    sleep(2)
    po1.login_button()
    sleep(5)

def test_163_01(driver):
    test_163_login(driver)
    po2=Page1(driver)
    po2.open_url('https://mail.163.com/js6/main.jsp?sid=GNtMoJvvaNuZmXhUMwCgPCegBpsJmMvH&df=mail163_letter#module=welcome.WelcomeModule%7C%7B%7D')
    sleep(2)
    po2.writer_xin()
    sleep(2)
    po2.person_shoujian()
    sleep(2)
    po2.click_fason()
    sleep(7)
    # po2.messages_zhuti()
    print("邮件发送成功")
    sleep(2)

# def test_163_02(driver):
#     test_163_login(driver)
#     po3=Page2(driver)
#     po3.open_url('https://mail.163.com/js6/main.jsp?sid=GNtMoJvvaNuZmXhUMwCgPCegBpsJmMvH&df=mail163_letter#module=welcome.WelcomeModule%7C%7B%7D')
#     sleep(2)
#     po3.click_shouxin()
#     sleep(2)
#     po3.button_shanchu()
#     sleep(2)
#     print('立即查询')